#!/usr/bin/perl

# $Id: RDF.pm 153 2009-02-02 23:26:40Z mail@tobyinkster.co.uk $

package Swignition::GenericParser::RDF;
1;

######################################################################
package Swignition::GenericParser::RDF::Comment;
######################################################################

use Swignition::RdfXmlParser;

sub is_enabled
{
	my $this = shift;
	return $this->{options}->{p_comments};
}

sub consume
{
	my $this = shift;
	my $src = $this->{_raw_source} || $this->{Source};
	
	my $i = 1;
	while ($src =~ /<!--\s*(.*)\s*-->/sg)
	{
		my $comment = $1;
		
		Swignition::RdfXmlParser::redland_parse(
			$this,
			'rdfxml',
			$comment,
			$this->graph,
			$this->graph(sprintf('Comment%02', $i++)));
	}
}

1;


######################################################################
package Swignition::GenericParser::RDF::Embedded;
######################################################################

sub is_enabled
{
	my $this = shift;
	return $this->{options}->{p_rdf};
}

sub consume
{
	my $this = shift;
	my @rdfs = $this->{DOM}->getElementsByTagNameNS("http://www.w3.org/1999/02/22-rdf-syntax-ns#", 'RDF');

	my $i = 1;
	foreach my $rdf (@rdfs)
	{
		my $comment = $1;
		
		Swignition::RdfXmlParser::redland_parse(
			$this,
			'rdfxml',
			$rdf->toString,
			$this->graph,
			$this->graph(sprintf('Embedded%02', $i++)));
	}		
}

1;

